package pkg

import (
	"cld-quick-cli/router/parameters"
	"github.com/go-playground/validator/v10"
)

// SignUpNewUserParamStructLevelValidation SignUpNewUser 结构体校验函数
func SignUpNewUserParamStructLevelValidation(sl validator.StructLevel) {
	su := sl.Current().Interface().(parameters.SignUpNewUser)
	//vof := reflect.ValueOf(su)

	//fields := vof.NumField() // 结构体字段数量！

	if su.Password != su.RePassword {
		// 输出错误提示信息，最后一个参数就是传递的param
		sl.ReportError(su.RePassword, "rePassword", "RePassword", "eqfield", "password")
	}
}
